package com.mogist.hqc.module.personal.ui

import android.content.Intent
import android.os.Build
import android.view.View
import android.view.WindowManager
import butterknife.OnClick
import butterknife.Optional
import com.mogist.hqc.R
import com.mogist.hqc.base.BaseMVPActivity
import com.mogist.hqc.module.common.ui.SettingActivity
import com.mogist.hqc.module.order.ui.OrderListActivity
import com.mogist.hqc.module.personal.contract.PersonalContract
import com.mogist.hqc.module.personal.presenter.PersonalPresenter
import com.mogist.hqc.util.Constant
import kotlinx.android.synthetic.main.activity_personal.*
import talex.zsw.basecore.util.DataTool
import talex.zsw.basecore.util.SpTool
import talex.zsw.basecore.util.glide.GlideApp

/**
 * 作用：我的
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class PersonalActivity : BaseMVPActivity<PersonalContract.Presenter>(), PersonalContract.View
{
    override fun initArgs(intent: Intent?)
    {
    }

    override fun initView()
    {
        setContentView(R.layout.activity_personal)
        mPresenter = PersonalPresenter(this)
        //当系统版本为4.4或者4.4以上时可以使用沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
        {
            //透明状态栏
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
        }
    }

    override fun initData()
    {

    }

    override fun onResume()
    {
        GlideApp.with(mIvPhoto.context)
                .load(SpTool.getString(Constant.STR_USER_PHOTO))
                .centerCrop()
                .into(mIvPhoto)
        mTvName.text = DataTool.formatPhone(SpTool.getString(Constant.STR_USER_NAME))
        super.onResume()
    }

    @Optional
    @OnClick(R.id.mIvBack,
             R.id.mIvSetting,
             R.id.mLLInfo,
             R.id.mIT1,
             R.id.mIT2,
             R.id.mIT3,
             R.id.mIT4,
             R.id.mTvCollect,
             R.id.mTvComment,
             R.id.mTvCommunity,
             R.id.mTvConsult)
    fun onViewClicked(view: View)
    {
        if (!isFastClick)
        {
            when (view.id)
            {
                R.id.mIvBack      ->
                {
                    finish()
                }
                R.id.mIvSetting   ->
                { // 设置
                    start(SettingActivity::class.java)
                }
                R.id.mLLInfo      ->
                { // 个人信息
                    start(InfoActivity::class.java)
                }
                R.id.mIT1         ->
                { // 全部订单
                    val intent = Intent(this@PersonalActivity, OrderListActivity::class.java)
                    intent.putExtra("pos", 0)
                    start(intent)
                }
                R.id.mIT2         ->
                { // 待支付
                    val intent = Intent(this@PersonalActivity, OrderListActivity::class.java)
                    intent.putExtra("pos", 1)
                    start(intent)
                }
                R.id.mIT3         ->
                { // 待游玩
                    val intent = Intent(this@PersonalActivity, OrderListActivity::class.java)
                    intent.putExtra("pos", 2)
                    start(intent)
                }
                R.id.mIT4         ->
                { // 待评论
                    val intent = Intent(this@PersonalActivity, OrderListActivity::class.java)
                    intent.putExtra("pos", 3)
                    start(intent)
                }
                R.id.mTvCollect   ->
                { // 收藏
                    start(CollectListActivity::class.java)
                }
                R.id.mTvComment   ->
                { // 评论
                    start(MyCommentListActivity::class.java)
                }
                R.id.mTvCommunity ->
                { // 我的帖子
                    start(MyCommunityListActivity::class.java)
                }
                R.id.mTvConsult   ->
                { // 咨询
                    start(ConsultListActivity::class.java)
                }
            }
        }
    }


}